﻿
$(document).ready(
    $(function () {
        $(".buttonSuppInfo").click(function () {
            $('#modalContent').load('/Supplemental/Output?id=2015', function () {
                $('#modal-section').modal({
                    backdrop: 'static',
                    keyboard: true
                }, 'show');

                bindForm(this);
            });
        });
    }
    ));

function bindForm(dialog) {

    $('form', dialog).submit(function() {
        $.ajax({
            url: this.action,
            type: this.method,
            data: $(this).serialize(),
            success: function(result) {
                if (result.success) {
                    $('#modal-section').modal('hide');
                    //Refresh
                    location.reload();
                } else {
                    $('#modalContent').html(result);
                    bindForm();
                }
            }
        });
        return false;
    });
};